package com.ynwa.thread.jcp.chapter3;

/**
 * @author gzd
 * @date 2018-05-26 下午10:24
 * @desc 没有做线程同步的情况下共享变量 程序清单 3-1
 */
public class WithoutSyncShareVar {

    private static boolean ready;

    private static int number;


    private static Runnable readerThread = () -> {
        while (!ready) {
            Thread.yield();
            System.out.println("---"+number);
        }
    };

    public static void main(String[] args) {
        new Thread(readerThread).start();

        number = 42;
        ready = true;
    }
}
